{include file='comdir/head.html'}
<body>
<div class="content">
    <div class="animated fadeInDown">
        <div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
        <div class="btn-box">
            <button class="btn btn-sm btn-success linkadd">添加</button>
        </div>
        <div class="searchBox">
            <form class="form-inline" action="javascript:void(0)">
                <span>
                友情分类：
                <select class="form-control classid"  name="classid">
                    <option value="-1">全部</option>
                    {foreach from=$linkclass item=vo}
                        <option value="{$vo.classid}">{$vo.classname}</option>
                    {/foreach}
                    </select>
                </span>
                <span>
                类型：
                <select class="form-control type">
                    <option value="-1">全部</option>
                    <option value="1">文章连接</option>
                    <option value="0">logo连接</option>
                   
                    </select>
                </span>
                
                <span><input type="button" class="form-control btn-blue searh" value="搜索"></span>
               
            </form>
        </div>
        <div class="table_list_wrap">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr>
						<th>LOGO</th>
                        <th>网站名称</th>
                        <th>网站站长或单位</th>
                        <th>分类名称</th>
                        <th>类型</th>
                        <th>URL</th>
                        <th>点击数</th>
                        <th>创建时间</th>
                        <th style="width:50px;">排序</th>
                        <th>推荐|审核</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody class="listtbody">
                    {foreach from=$list item=vo}
                    <tr class="link_{$vo.id}">
						<td>
						{if $vo.logo}<img style="max-widht:100px;max-height:30px;" src="{$getConfig.upload_http}{$vo.logo}">{/if}
						</td>
						
                        <td>{$vo.sitename}</td>
                        <td>{$vo.webmaster}</td>
                        <td>{$vo.classname}</td>
                        <td>{if $vo.type==1}文字连接{else}logo连接{/if}</td>
                        <td>{$vo.url}</td>
                     
                        
                        <td>{$vo.hits}</td>
                        <td>{if $vo.addtime}{$vo.addtime|date_format:'%Y-%m-%d %H:%M:%S'}{/if}</td>
                        <td><input type="text"  class="form-control editorderid" data-id='{$vo.id}' data-orderid='{$vo.orderid}' name="orderid" value='{$vo.orderid}'></td>
                        <td>
                            <span data-id='recommend_{$vo.id}' onclick="protruding({$vo.recommend},this)" class='{if $vo.recommend==1}protruding{else}noprotruding{/if}'>荐</span>&nbsp;&nbsp;
                            <span data-id='verify_{$vo.id}' onclick="protruding({$vo.verify},this)" class="{if $vo.verify==1}protruding{else}noprotruding{/if}">审</span></td>
                            
                        <td>
                            <input type="button" onclick="edit({$vo.id})" class="btn btn-xs btn-warning" value="编辑">
                            <input type="button" onclick="del({$vo.id})" class="btn btn-xs btn-danger" value="删除">
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="page-box">
        <div class="page">
            {$pageshow}
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
    var _URL='{$_URL}';
    {literal}
    $(function(){
        //更新排序
        $('.editorderid').blur(function(){
            var url=_URL+"Link/edit";
            var orderid=$(this).val();
            var id=$(this).attr('data-id');
            var orderid_old=$(this).attr('data-orderid');
            if(orderid==orderid_old){
                return false;
            }
            _ajaxs.post(url,"editorderid=1&orderid="+orderid+"&id="+id,function(data){
                if(data.status){
                    layer.msg(data.msg,{icon: 1}, function(){return false;});
                }else{
                    layer.msg(data.msg,{icon: 2}, function(){return false;});
                }
            });
        })
        //搜索
        $('.searh').click(function(){
            ajaxpage(false);
        })
        $('.linkadd').click(function(){
            window.location.href=_URL+"Link/add";
        })
    })
    //推荐和审核
    var protrudingstatus=true;
    function protruding(value,objthis){
        var obj=$(objthis);
        var field_id=obj.attr('data-id');
        if(value==0){value=1;}else{value=0;}
        var url=_URL+"Link/edit";
        if(protrudingstatus===false){return false;}
        //protrudingstatus=false;
		_ajaxs.post(url,"protrudingstatus=1&value="+value+'&field_id='+field_id,function(data){
			protrudingstatus=true;
			if(data.status){
				layer.msg(data.msg,{icon: 1}, function(){
					obj.removeAttr('onclick');
					obj.attr('onclick','protruding('+value+',this)');
					if(value==1){
						obj.removeClass('noprotruding');
						obj.addClass('protruding');
					}
					if(value==0){
						obj.removeClass('protruding');
						obj.addClass('noprotruding');
					}
				})
			}else{
				layer.msg(data.msg,{icon:2}, function(){return false;})
			}
			
		});
    }
    function edit(id){
        window.location.href=_URL+"Link/edit?id="+id;
    }
    function del(id){
        var url=_URL+"Link/classdel";
        var del_all=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'站点'},function(){
            _ajaxs.post(url,'classid='+id,function(data){
                layer.msg(data.msg,{icon: 1}, function(){});
                if(data.status){
                    $('.siteid_'+id).remove();
                }
                layer.close(index);
            })
        });
    }
    function ajaxpage(page){
        url='';
        url+=_sousuo.value('.title','title');
        url+=_sousuo.selected('.classid','classid',-1);
        url+=_sousuo.selected('.type','type',-1);
        if(page){
            url+="page="+page;
        }else{
            if(url!=''){
                url=url.substring(0,url.length-1);
            }
        }
        _ajaxs.post(_URL+"Link/lists",url,function _return(data){
            $('.listtbody').html('');
            $('.listtbody').html(data.data.list);
            if(data.data.pageshow){
                $('.page').html(data.data.pageshow);
            }else{
                $('.page').html('');
            }
        },'json')
    }
    {/literal}
</script>

</body>
</html>